package mediatheque.model;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;

public class AudioModel extends DocumentModel {
	
	private static final long serialVersionUID = -7707160444102303312L;
	private String duree;
	
	private static int NOMBRE_AUDIO = 0;
	
	public AudioModel() {
		this("N/A", "N/A", "N/A", true, null, "N/A");
	}

	public AudioModel(String nom, String etat, String description, boolean empruntable,
			ArrayList<String> listeTheme, String duree) {
		super("Audio", nom, etat, description, empruntable, listeTheme);

		this.duree = duree;

		NOMBRE_AUDIO++;
		this.setIdentifiant(genererIdentifiant());
	}
	
	private String genererIdentifiant() {
		return "AU-" + NOMBRE_AUDIO;
	}

	public String getDuree() {
		return duree;
	}
	
	public void setDuree(String duree) {
		this.duree = duree;
	}
	

	private void writeObject(ObjectOutputStream oos) throws IOException {
		oos.defaultWriteObject();
		oos.writeObject(new Integer(NOMBRE_AUDIO));
	}

	private void readObject(ObjectInputStream ois)
			throws ClassNotFoundException, IOException {
		ois.defaultReadObject();
		NOMBRE_AUDIO = (Integer) ois.readObject();
	}

}
